package com.qf.service.Impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.qf.dao.RiderMapper;
import com.qf.entitys.Rider;
import com.qf.service.RiderService;
import org.springframework.stereotype.Service;
import org.springframework.util.DigestUtils;

import javax.annotation.Resource;
import java.util.List;

@Service
public class RiderServiceImpl implements RiderService {

    @Resource
    private RiderMapper mapper;

    @Override
    public int deleteByPrimaryKey(Integer riderId) {
        return 0;
    }

    @Override
    public Rider selectAllByloginName(String loginname) {
        return mapper.selectAllByloginName(loginname);
    }

    @Override
    public Rider selectRiderByLoginName(String loginname) {
        return mapper.selectRiderByLoginName(loginname);
    }

    @Override
    public int insert(Rider record) {
        String s = DigestUtils.md5DigestAsHex(record.getLogin_pwd().getBytes());
        record.setLogin_pwd(s);
        record.setRiderstatus(false);
        return mapper.insert(record);
    }

    @Override
    public int insertSelective(Rider record) {
        return 0;
    }

    @Override
    public Rider selectByPrimaryKey(Integer riderId) {
        return null;
    }

    @Override
    public int updateByPrimaryKeySelective(Rider record) {
        return 0;
    }

    @Override
    public int updateByPrimaryKey(Rider record) {
        return 0;
    }

    @Override
    public PageInfo<Rider> selectAll(Integer pageindex, Rider record) {
        PageHelper.startPage(pageindex,10);
        List<Rider> list = mapper.selectAll(record);
        //封装分页里的list数据属性
        PageInfo<Rider> businessPageInfo = new PageInfo<>(list);
        return businessPageInfo;
    }

    @Override
    public PageInfo<Rider> selectNo(Integer pageindex, Rider record) {
        PageHelper.startPage(pageindex,10);
        List<Rider> list = mapper.selectriderstatus0(record);
        //封装分页里的list数据属性
        PageInfo<Rider> businessPageInfo = new PageInfo<>(list);
        return businessPageInfo;
    }

    @Override
    public PageInfo<Rider> selectBack(Integer pageindex, Rider record) {
        PageHelper.startPage(pageindex,10);
        List<Rider> list = mapper.selectriderstatus2(record);
        //封装分页里的list数据属性
        PageInfo<Rider> businessPageInfo = new PageInfo<>(list);
        return businessPageInfo;
    }
    @Override
    public int updateRiderstatus(Integer id,Integer status) {
        return mapper.updateRiderstatus(id,status);
    }

    @Override
    public int delRiderstatus(Integer id) {
        return mapper.delRiderstatus(id);
    }

}
